package com.gome.ocean.service.gddl.impl;

import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.gome.ocean.dao.gddl.GroupDAO;
import com.gome.ocean.dao.model.gddl.GroupBO;
import com.gome.ocean.service.gddl.GroupService;

@Service("groupService")
@Transactional("transactionManager")
public class GroupServiceImpl implements GroupService {

    @Autowired
    private GroupDAO groupDAO;

    @Override
    public boolean insertGroupBO(GroupBO groupBO) {
        return groupDAO.insertGroupBO(groupBO) > 0;
    }

    @Override
    public boolean removeGroupBOById(Long id) {
        return groupDAO.removeGroupBOById(id) > 0;
    }

    @Override
    public boolean updateGroupBOById(GroupBO groupBO) {
        return groupDAO.updateGroupBOById(groupBO) > 0;
    }

    @Override
    public GroupBO findGroupBOById(Long id) {
        return groupDAO.findGroupBOById(id);
    }

    @Override
    public GroupBO findGroupBOAppIdAndGroupName(Long appId, String groupName) {
        return groupDAO.findGroupBOAppIdAndGroupName(appId, groupName);
    }

    @Override
    public List<GroupBO> findGroupBOByAppId(Long appId) {
        return groupDAO.findGroupBOByAppId(appId);
    }

    @Override
    public GroupBO findGroupBOByGroupName(String groupName) {
        return groupDAO.findGroupBOByGroupName(groupName);
    }

    @Override
    public Page<GroupBO> findAllGroups(int pageNum, int pageSize) {
        return (Page) groupDAO.findAllGroups(new RowBounds(pageNum, pageSize));
    }

    @Override
    public List<GroupBO> findLikeGroupBOByGroupName(String groupName) {
        return groupDAO.findLikeGroup(groupName);
    }

}
